<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
    <head>
        <title><?php echo C('WEB_SITE_TITLE');?></title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">

        <link href="__RES__/css/login.css" rel="stylesheet" type="text/css"/>
        <script src="__RES__/js/jquery-1.11.1.min.js" type="text/javascript"></script>
        
    </head>
    <body>
        <div class="Head">
            <div class="Links">
                <div style="float:right;">
                    <button type="button" class="Button" onclick="admin();">
                        访问后台
                    </button>
                </div>
            </div>
            <div class="logo">
               <img style="border:0 none;" src="__RES__/img/logo.gif"/>
            </div>
            <h3 style="float:right;margin-right: 40px; color:#333;">
                工程技术中心学习系统
            </h3>
        </div>

        <div class="Main">
            <div class="MainL">
                <div class="LTop">
                    
                </div>
                <div class="LContent"></div>
                <div class="LB"></div>
            </div>
            <div class="MainR">

                
    <h3>用户注册</h3>
    <div id="logArea">
        <div class="Error">
            <div class="NoteError"></div>
        </div>
        <form id="registForm" method="post" action="">
            <table class="loginTable">
                <tr>
                    <th>员工编号</th>
                    <td><input type="text" id="username" name="username" class="input" required="required"/></td>
                    <td>(8位数字)</td>
                </tr>
                <tr>
                    <th>姓　名</th>
                    <td><input type="text" id="real_name" name="real_name" class="input" required="required"/></td>
                    <td>(中文)</td>
                </tr>

                <tr>
                    <th>密　码</th>
                    <td><input type="password" id="password" name="password" class="input" autocomplete="off" required="required"/></td>
                    <td></td>
                </tr>
                <tr>
                    <th>密码确认</th>
                    <td><input type="password" id="c_password" name="c_password" class="input" autocomplete="off" required="required"/></td>
                    <td></td>
                </tr>
<!--                <tr>
                    <th>邮  箱</th>
                    <td><input type="text" id="email" name="email" class="input" required="required"/></td>
                    <td></td>
                </tr>-->
                <tr>
                    <th>电　话</th>
                    <td><input type="text" id="tel" name="tel" class="input" required="required"/></td>
                    <td></td>
                </tr>

                <tfoot>
                    <tr>
                        <td></td>
                        <td colspan="2" >
                            <button  type="button" class="Button" id="btnSubmit">
                                确　认
                            </button>
                            <button type="button" id="btnBack" class="Button" onclick="location.href = '<?php echo U(index);?>';">
                                返  回 
                            </button>

                        </td>
                    </tr>
                </tfoot>
            </table>
        </form>

    </div>

                
            </div>

            <div class="footer">
                <div class="footerBg">
                    <div class="copyright">
                         Copyright &copy; 2014  长虹-工程技术中心
                    </div>
                </div>
            </div>
        </div>

        
    <script>
        $(function () {
            $("#btnSubmit").click(function () {

                var username = $.trim( $("#username").val() );
                var real_name = $.trim( $("#real_name").val() );
                var password = $.trim( $("#password").val() );
                var c_password = $.trim( $("#c_password").val() );
                var email = $.trim( $("#email").val() );
                var tel = $.trim( $("#tel").val() );
                
                if( username === "" || real_name === "" || password === "" || c_password === "" || tel === ""){
                    alert("请将注册信息填写完整！");
                    return ;
                }

                if( !username.match(/^[0-9]{8}$/gi) ){
                    alert("员工编号不合要求！");
                    $("#username").focus();
                    return;
                }

                if( real_name.match(/^[u4e00-u9fa5]*$/) ){
                    alert("请输入中文！");
                    $("#real_name").focus();
                    return;
                }
                
                if( password !== c_password ){
                    alert("密码不一致！");
                    return;
                }
               
//                if( !email.match(/^[a-z]([a-z0-9]*[-._]?[a-z0-9]+)*@([a-z0-9]*[-_]?[a-z0-9]+)+[.][a-z]{2,3}([.][a-z]{2})?$/i) ){
//                    alert("邮箱格式不对！");
//                    return;
//                }
                
                if(!tel.match(/^[0-9]*$/gi)){
                    alert("电话号码必须是数字！");
                    return;
                }
                
                var sendData = $("#registForm").serialize();
 
                $.post("<?php echo U('runRegist');?>", sendData).done(function (responseData) {
                    //console.log(responseData);
                    if (responseData.status === 1) {
                        alert(responseData.info);
                        location.href = responseData.jumpUrl;
                    } else {
                        alert(responseData.info);
                        location.href = responseData.jumpUrl;
                    }
                });
                
                
            });
        });
    </script>

        
        <script>
            function admin(){
                location.href = "<?php echo U('Admin/Login/index');?>";
            }
        </script>
    </body>
</html>